//动态路由
import { isNullOrUndefind, JsonExcludeNullOrUndefind } from '../utils/utils';
import {getnavigation,getneedLoginRouterList} from '@/api/head'
const state={
    headnavigationList:[],  //头部导航栏
    needLoginRouterList:[],//需要登录才能访问的路由

}

const actions={
        getheadnavigationList(context){
            getnavigation().then(navigation=>{
                context.commit('setheadnavigationList',navigation)
              })
        },
        getneedLoginRouterList(context){
            // console.log('1')
                getneedLoginRouterList().then(list=>{
                    context.commit('setneedLoginRouterList',list)
                })
        }
}
const mutations={
    setheadnavigationList(state,navigation){
        state.headnavigationList=navigation;
    },
    setneedLoginRouterList(state,list){
        state.needLoginRouterList=list;
      window.sessionStorage.setItem('needLoginRouterList',JsonExcludeNullOrUndefind(list))
    },
   
}
const getters={

}
export default {
    namespaced: true,
    state,
    actions,
    getters,
    mutations
  }